API Documentation
Vector.h
1 // Vector.h
3 //
5 
6 namespace nkMaths
7 {
11  class Vector : public ByteAlignedClass<16>
12  {
13  public :
14 
15  // Attributes
16  float _x ;
17  float _y ;
18  float _z ;
19  float _w ;
20 
21  public :
22 
27  Vector () ;
36  Vector (float x, float y) ;
46  Vector (float x, float y, float z) ;
55  Vector (float x, float y, float z, float w) ;
61  Vector (const Vector& other) ;
67  Vector (const IntVector& other) ;
68 
69  // Length
73  float getLengthVec2 () const ;
77  float getLengthVec3 () const ;
81  float getLengthVec4 () const ;
87  float getLengthSquaredVec2 () const ;
93  float getLengthSquaredVec3 () const ;
99  float getLengthSquaredVec4 () const ;
100  // Distance
105  float getDistanceVec2 (const Vector& other) const ;
110  float getDistanceVec3 (const Vector& other) const ;
115  float getDistanceVec4 (const Vector& other) const ;
122  float getDistanceSquaredVec2 (const Vector& other) const ;
129  float getDistanceSquaredVec3 (const Vector& other) const ;
136  float getDistanceSquaredVec4 (const Vector& other) const ;
137 
143  void normalizeVec2 () ;
149  void normalizeVec3 () ;
153  void normalizeVec4 () ;
166  // Dot product
173  float dotProductVec2 (const Vector& other) const ;
180  float dotProductVec3 (const Vector& other) const ;
187  float dotProductVec4 (const Vector& other) const ;
188  // Cross product
194  void setAsCrossVec3 (const Vector& other) ;
201  Vector getCrossVec3 (const Vector& other) const ;
202 
203  // Practical
214  void fromString (const nkMemory::StringView& str) ;
215 
216  // Operators
223  Vector& operator= (const Vector& other) ;
230  Vector& operator= (const IntVector& other) ;
237  Vector operator+ (const Vector& other) const ;
243  void operator+= (const Vector& other) ;
250  Vector operator- (const Vector& other) const ;
256  void operator-= (const Vector& other) ;
263  Vector operator* (const Vector& other) const ;
269  void operator*= (const Vector& other) ;
276  Vector operator* (const Quaternion& other) const ;
282  void operator*= (const Quaternion& other) ;
289  Vector operator* (const Matrix& mat) const ;
295  void operator*= (const Matrix& other) ;
302  Vector operator* (float coeff) const ;
308  void operator*= (float coeff) ;
315  Vector operator/ (const Vector& other) const ;
321  void operator/= (const Vector& other) ;
328  Vector operator/ (float coeff) const ;
334  void operator/= (float coeff) ;
341  bool operator== (const Vector& other) const ;
348  bool operator!= (const Vector& other) const ;
355  bool operator< (const Vector& other) const ;
362  bool operator<= (const Vector& other) const ;
369  bool operator> (const Vector& other) const ;
376  bool operator>= (const Vector& other) const ;
377 
378  // Statics
379  // Distance
387  static float distanceVec2 (const Vector& a, const Vector& b) ;
395  static float distanceVec3 (const Vector& a, const Vector& b) ;
403  static float distanceVec4 (const Vector& a, const Vector& b) ;
411  static float distanceSquaredVec2 (const Vector& a, const Vector& b) ;
419  static float distanceSquaredVec3 (const Vector& a, const Vector& b) ;
427  static float distanceSquaredVec4 (const Vector& a, const Vector& b) ;
428  // Dot product
436  static float dotVec2 (const Vector& a, const Vector& b) ;
444  static float dotVec3 (const Vector& a, const Vector& b) ;
452  static float dotVec4 (const Vector& a, const Vector& b) ;
453  // Cross product
461  static Vector crossVec3 (const Vector& a, const Vector& b) ;
462  } ;
463 
464  using FloatVector = Vector ;
465 }
nkMaths::Vector::distanceVec3
static float distanceVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthVec4
float getLengthVec4() const
nkMaths::Vector::getDistanceSquaredVec2
float getDistanceSquaredVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector(float x, float y, float z, float w)
nkMaths::Vector::distanceSquaredVec2
static float distanceSquaredVec2(const Vector &a, const Vector &b)
nkMaths::IntVector
A 4-component vector class, with integers.
Definition: IntVector.h:12
nkMaths::Vector::distanceVec2
static float distanceVec2(const Vector &a, const Vector &b)
nkMaths::Vector::operator>
bool operator>(const Vector &other) const
nkMaths::Vector::setAsCrossVec3
void setAsCrossVec3(const Vector &other)
nkMaths::Vector::getCrossVec3
Vector getCrossVec3(const Vector &other) const
nkMaths
Encompasses all API of component NilkinsMaths.
Definition: IntVector.h:7
nkMaths::Vector::operator==
bool operator==(const Vector &other) const
nkMaths::Vector::operator<
bool operator<(const Vector &other) const
nkMaths::Vector::operator+=
void operator+=(const Vector &other)
nkMaths::Quaternion
A quaternion, symbolizing rotations as a 4D vector.
Definition: Quaternion.h:14
nkMaths::Vector::operator+
Vector operator+(const Vector &other) const
nkMaths::Vector::getLengthVec3
float getLengthVec3() const
nkMaths::Vector::distanceSquaredVec4
static float distanceSquaredVec4(const Vector &a, const Vector &b)
nkMaths::Vector::getDistanceVec4
float getDistanceVec4(const Vector &other) const
nkMaths::Vector::dotVec3
static float dotVec3(const Vector &a, const Vector &b)
nkMaths::Vector::getLengthSquaredVec2
float getLengthSquaredVec2() const
nkMaths::Vector::dotVec4
static float dotVec4(const Vector &a, const Vector &b)
nkMaths::Vector::_x
float _x
X component of the vector.
Definition: Vector.h:16
nkMaths::Matrix
Represents a 4x4 float matrix.
Definition: Matrix.h:14
nkMaths::Vector::getDistanceVec2
float getDistanceVec2(const Vector &other) const
nkMaths::Vector::Vector
Vector()
nkMaths::Vector::normalizeVec2
void normalizeVec2()
nkMaths::Vector::normalizeVec3
void normalizeVec3()
nkMaths::Vector::getDistanceSquaredVec4
float getDistanceSquaredVec4(const Vector &other) const
nkMaths::Vector::operator*
Vector operator*(const Vector &other) const
nkMaths::Vector::distanceSquaredVec3
static float distanceSquaredVec3(const Vector &a, const Vector &b)
nkMaths::Vector::operator-=
void operator-=(const Vector &other)
nkMaths::Vector::operator<=
bool operator<=(const Vector &other) const
nkMaths::Vector::Vector
Vector(const Vector &other)
nkMaths::Vector::operator/=
void operator/=(const Vector &other)
nkMemory::String
Class holding information about a string, with ownership over the data.
Definition: String.h:22
nkMemory::StringView
Class holding information about a string, with no ownership over the data.
Definition: StringView.h:22
nkMaths::Vector::Vector
Vector(const IntVector &other)
nkMaths::Vector::crossVec3
static Vector crossVec3(const Vector &a, const Vector &b)
nkMaths::Vector::fromString
void fromString(const nkMemory::StringView &str)
nkMaths::Vector::toString
nkMemory::String toString() const
nkMaths::Vector::dotProductVec3
float dotProductVec3(const Vector &other) const
nkMaths::Vector::operator>=
bool operator>=(const Vector &other) const
nkMaths::Vector::_z
float _z
Z component of the vector.
Definition: Vector.h:18
nkMaths::Vector::_w
float _w
W component of the vector.
Definition: Vector.h:19
nkMaths::Vector::getLengthSquaredVec3
float getLengthSquaredVec3() const
nkMaths::Vector::dotProductVec4
float dotProductVec4(const Vector &other) const
nkMaths::Vector::getDistanceVec3
float getDistanceVec3(const Vector &other) const
nkMaths::Vector::getNormalizedVec2
Vector getNormalizedVec2() const
nkMaths::Vector::getNormalizedVec3
Vector getNormalizedVec3() const
nkMaths::Vector::Vector
Vector(float x, float y)
nkMaths::Vector::_y
float _y
Y component of the vector.
Definition: Vector.h:17
nkMaths::Vector::getNormalizedVec4
Vector getNormalizedVec4() const
nkMaths::Vector::getLengthVec2
float getLengthVec2() const
nkMaths::Vector::dotProductVec2
float dotProductVec2(const Vector &other) const
nkMaths::Vector::operator-
Vector operator-(const Vector &other) const
nkMaths::Vector::getLengthSquaredVec4
float getLengthSquaredVec4() const
nkMaths::Vector::operator!=
bool operator!=(const Vector &other) const
nkMaths::Vector::operator*=
void operator*=(const Vector &other)
nkMaths::Vector::operator/
Vector operator/(const Vector &other) const
nkMaths::Vector::getDistanceSquaredVec3
float getDistanceSquaredVec3(const Vector &other) const
nkMaths::Vector::operator=
Vector & operator=(const Vector &other)
nkMaths::Vector::Vector
Vector(float x, float y, float z)
nkMaths::Vector
A 4-component vector class, with floats.
Definition: Vector.h:12
nkMaths::Vector::distanceVec4
static float distanceVec4(const Vector &a, const Vector &b)
nkMaths::Vector::normalizeVec4
void normalizeVec4()
nkMaths::Vector::dotVec2
static float dotVec2(const Vector &a, const Vector &b)